<template>
    <h3>key属性添加到v-for中</h3>
    <p v-for="{item,index} in names" :key="index"></p>
    <div v-for = "item of result":key = "item.id" >
        <p v-if="item.id == '42' || item.id == '45'">{{ item.id }}</p>
        <img :src="item.imgUrl" alt="" v-if="item.id == '42' || item.id == '45'">
    </div>
</template>
<script>
export default{
    data(){
        return {
            names:["百战程序员","尚学堂","IT"],
            result: [
                {
                    "id": "42",
                    "imgUrl": "https://yjy-teach-oss.oss-cn-beijing.aliyuncs.com/meikou/banner/nuandong_sj.png",
                    "hrefUrl": "/category/1181622006",
                    "type": "1"
                },
                {
                    "id": "48",
                    "imgUrl": "https://yjy-teach-oss.oss-cn-beijing.aliyuncs.com/meikou/banner/nvshen_sj.png",
                    "hrefUrl": "/category/1181622003",
                    "type": "1"
                },
                {
                    "id": "45",
                    "imgUrl": "https://yjy-teach-oss.oss-cn-beijing.aliyuncs.com/meikou/banner/xinnian_sj.png",
                    "hrefUrl": "/category/1181622001",
                    "type": "1"
                }
            ]
        }
    }
}
</script>